﻿/*
 * Copyright © 2011 Tristan Reeves, treeves@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using Sprinkles.Tests.TestClasses;

namespace Sprinkles.Tests.DeploymentHosts
{
    public class DummyHost3 : DeploymentHost
    {
        protected override bool Include
        {
            get { return this.UserContextIsNotMarked(); }
        }

        public static string Qualify(string name)
        {
            return "DummyHost3." + name;
        }

        protected override void RegisterDeployments()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .InitMethod(x => x.HelloWorld())
                .Done();

            Register<InitDestroyTestClass>()
                .Name(Qualify("destroy"))
                .Singleton(false)
                .LazyInit(true)
                .DestroyMethod(x => x.Goodbye())
                .Done();

            Register<InitDestroyTestClass>()
                .Name(Qualify("init-destroy"))
                .Singleton(false)
                .LazyInit(true)
                .InitMethod(x => x.HelloWorld())
                .DestroyMethod(x => x.Goodbye())
                .Done();
        }
        public void IllegalInitMethod1()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .InitMethod(x => x.HelloWorld2(5))
                .Done();
        }
        public void IllegalInitMethod2()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .InitMethod(x => DummyHost3.Qualify("123"))
                .Done();
        }
        public void IllegalInitMethod3()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .InitMethod(x => (new InitDestroyTestClass()).HelloWorld())
                .Done();
        }
        public void IllegalDestroyMethod1()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .DestroyMethod(x => x.Goodbye2(5))
                .Done();
        }
        public void IllegalDestroyMethod2()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .DestroyMethod(x => DummyHost3.Qualify("123"))
                .Done();
        }
        public void IllegalDestroyMethod3()
        {
            Register<InitDestroyTestClass>()
                .Name(Qualify("init"))
                .Singleton(false)
                .LazyInit(true)
                .DestroyMethod(x => (new InitDestroyTestClass()).Goodbye())
                .Done();
        }
    }
}
